package com.hpf.lease.web.admin.controller;

import com.hpf.lease.common.result.Result;
import com.hpf.lease.model.bean.FacilityInfo;
import com.hpf.lease.web.admin.service.FacilityInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Tag(name = "配套信息管理")
@RequestMapping("/admin/facility")
public class FacilityInfoController {
    @Resource
    FacilityInfoService facilityInfoService;
    @PostMapping("/saveOrUpdate")
    @Operation(summary = "根据id添加或修改配套信息")
    public Result<Object> saveOrUpdate(@RequestBody FacilityInfo facilityInfo){
        return Result.build(facilityInfoService.saveOrUpdateInfo(facilityInfo));
    }
    @GetMapping("/list")
    @Operation(summary = "查询配套信息(可能有type条件)")
    public Result<List<FacilityInfo>> selectBySome(@RequestParam(required = false) Integer type){
        List<FacilityInfo> list = facilityInfoService.listByType(type);
        return Result.ok(list);
    }
    @DeleteMapping("/deleteById")
    @Operation(summary = "根据id删除配套信息")
    public Result<Object> deleteById(@RequestParam(required = false) Long id){
        return Result.build(facilityInfoService.removeById(id));
    }

}
